package utils

import (
	"math/rand"
	"time"
)

const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

func RandomString(pixff string, strlen int) string {
	rand.Seed(time.Now().UTC().UnixNano())
	result := make([]byte, strlen)
	for i := 0; i < strlen; i++ {
		result[i] = alphanum[rand.Intn(len(alphanum))]
	}
	return time.Now().Format("20151212010203") + "-" + pixff + "-" + string(result)
}

func Random32str() string {
	rand.Seed(time.Now().UTC().UnixNano())
	result := make([]byte, 32)
	for i := 0; i < 32; i++ {
		result[i] = alphanum[rand.Intn(len(alphanum))]
	}
	return string(result)
}

func OrderId() string {
	rand.Seed(time.Now().UTC().UnixNano())
	result := make([]byte, 11)
	for i := 0; i < 11; i++ {
		result[i] = alphanum[rand.Intn(len(alphanum))]
	}
	return time.Now().Format("20060102") + "-" + string(result)
}
